#ifndef QEXPPART_H
#define QEXPPART_H

#include <QObject>
#include <QStringList>
#include <QHash>
#include <QRegExp>
#include <QString>

#include "exp_define.h"
#include "regular_expression.h"
#include "qerreur.h"

class __declspec(dllexport) QEXPPart
{

public:
	QEXPPart(QStringList,QStringList,quint32 line);
	~QEXPPart();
	bool equalsTo(QString field,QString compare);
	bool contains(QString field,QString text);
	void replace(QString field, QString replacement);
	QString get(QString field) const;
	QString getNormalized(QString field) const;
	QString rebuild(QStringList);
	QString key(quint8 errors) const;
	bool hasValidKey() const;
	quint8 hasErrors() const { return m_errors.size(); }
	void addError(QErreur* error); 
	QErreur* getError(quint8 index) const;
	void clearError() { m_errors.clear(); }
	quint32 line() const { return m_line; }
private:
	QString buildKey();
	void add(QString properties,QString field,QString regExp, quint32 capture=0);
	void add(QString properties,QString add);
	QString normalize(QString raw);

	QHash<QString,QString> m_properties;
	QList<QErreur*> m_errors;
	quint32 m_line;
};

#endif // QEXPPART_H
